from django.urls import path
from rest_framework.routers import DefaultRouter

from . import views
urlpatterns = [
    #  /channels/ 获取首页左侧栏中的频道列表
    path('channels/', views.ChannelAPIView.as_view()),
    #  /article/  发表文章
    path('article/', views.ArticleAPIView.as_view()),
    #  /article/{id}/   根据id获取文章详情
    path('article/<int:pk>/', views.GetArticleAPIView.as_view()),
    #  /article/{id}/channel/  获取某个频道下的文章
    path('article/<i:id>/channel/', views.ArticleListView.as_view()),
    #  /article/{id}/publish_comment/  评论文章
    path('article/<int:pk>/publish_comment/', views.ArticleCreateAPIView.as_view()),
    #   /article/{id}/collect/  收藏文章
    path('article/<int:pk>/collect/', views.CollectArticleView.as_view()),
    # 搜索

]

#创建router实例
router = DefaultRouter()
#注册路由
router.register('articles/search',views.ArticleSearchViewSet,basename='search')
#将router生成的路由追加到urlpatterns中
urlpatterns += router.urls
